﻿Imports System.Data.SqlClient
Public Class FormCategoryEditor

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Cmd.Parameters("@CategoryName") = Me.TextBox1.Text
        Cmd.Parameters("@TypeId") = Me.ComboBox1.SelectedValue

        Cmd.ExecuteNonQuery("insert into Category values(@CategoryName,@TypeId,1);")
    End Sub

    Private Sub FormCategoryEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dt As DataTable = Cmd.ExecuteDataTable("select * from Type")
        Me.ComboBox1.DisplayMember = "TypeName"
        Me.ComboBox1.ValueMember = "TypeId"
        Me.ComboBox1.DataSource = dt
    End Sub
End Class